package com.example.spider.event;

import com.example.spider.task.Task;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;

/**
 * 服务拒绝，任务被丢弃
 */
@Getter
public class DropTaskEvent extends ApplicationEvent {

    private final transient Exception exception;

    public DropTaskEvent(Task<?> task, Exception exception) {
        super(task);
        this.exception = exception;
    }

    public <T extends Task<?>> T getTask() {
        return (T) getSource();
    }
}